/*
 * Project:     My Project Work, Copyright (C) 2011
 * Created at:  05.08.2011
 */
package de.myprojectwork.model.dto;

import java.util.Date;
import org.apache.commons.lang3.time.DateFormatUtils;

/**
 * Tabelle <code>PROJECT</code>
 * 
 * @author Chris Holdschuh
 */
public class Project extends AbstractDto {
    
    private int     number;
    private String  name;
    private String  customer;
    private Date    dateStart;
    private Date    dateEnd;
    private String  statusName;
    private int     statusPercent;
    
    private Status  status;

    public Project() {
        // leer
    }

    public String getCustomer() {
        return customer;
    }

    public void setCustomer(String customer) {
        this.customer = customer;
    }

    public Date getDateEnd() {
        return dateEnd;
    }

    public void setDateEnd(Date dateEnd) {
        this.dateEnd = dateEnd;
    }

    public Date getDateStart() {
        return dateStart;
    }

    public void setDateStart(Date dateStart) {
        this.dateStart = dateStart;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getNumber() {
        return number;
    }

    public void setNumber(int number) {
        this.number = number;
    }

    public Status getStatus() {
        return status;
    }

    public void setStatus(Status status) {
        this.status = status;
        statusName = status.getName();
    }
    
    public String getStatusName() {
        return statusName;
    }

    public void setStatusName(String statusName) {
        this.statusName = statusName;
        for(Status s : Status.values()) {
            if (s.getName().equalsIgnoreCase(statusName)) {
                status = s;
            }
        }
    }

    public int getStatusPercent() {
        return statusPercent;
    }

    public void setStatusPercent(int statusPercent) {
        this.statusPercent = statusPercent;
    }

    @Override
    public String toString() {
        return getClass().getSimpleName() + " {"
                + "id=" + getId() + ", "
                + "number=" + number + "; "
                + "name=" + name + "; "
                + "customer=" + customer + ", "
                + "dateStart=" + (dateStart != null ? DateFormatUtils.format(dateStart, "dd.MM.yyyy") : "null") + ", "
                + "dateEnd=" + (dateEnd != null ? DateFormatUtils.format(dateEnd, "dd.MM.yyyy") : "null") + ", "
                + "status=" + status + ", "
                + "statusPercent=" + statusPercent + ", "
                + "update=" + DateFormatUtils.format(getUpdate(), "dd.MM.yyyy")
                + "}";
        
    }
    
    public enum Status {
        
        ABGEBROCHEN         ("Abgebrochen"),
        BEENDET             ("Beendet"),
        AKTIV               ("Aktiv");
        
        private String name;

        private Status(String name) {
            this.name = name;
        }

        public String getName() {
            return name;
        }
    }
    
}
